package com.ks.bff.service.impl;

import com.ks.bff.service.IOrderService;
import com.ks.order.feign.OrderFeignClient;
import com.ks.order.model.request.ReqCreateorderDto;
import com.ks.product.feign.ProductFeignClient;
import com.ks.product.model.request.ReqDecreaseStockDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    private OrderFeignClient orderFeignClient;
    @Autowired
    private ProductFeignClient productFeignClient;

    @Override
    public void createOrder(ReqCreateorderDto request) {
        orderFeignClient.createOrder(request);
        ReqDecreaseStockDto productRequest = new ReqDecreaseStockDto();
        productRequest.setQuantity(request.getQuantity());
        productFeignClient.decreaseStock(productRequest);
    }
}
